package com.metaera.app.ui.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.metaera.app.LocalConfigStore;
import com.metaera.app.R;
import com.metaera.app.data.model.UserDetailsResponse;
import com.metaera.app.ui.core.BaseActivity;
import com.metaera.app.utils.ActivityTitleHelper;


/**
 * 账号与安全
 */
public class AccountSafeActivity extends BaseActivity implements View.OnClickListener {

    @Override
    protected int getContentLayoutId() {

        return R.layout.activity_account_safe;
    }

    @Override
    protected void initialize(Bundle savedInstanceState) {
        ActivityTitleHelper.setTitle(this, R.string.account_safe);
        // find
        TextView tvPhoneNumber = findViewById(R.id.tv_phone_number);

        // listener
        findViewById(R.id.tv_unregister).setOnClickListener(this);
        findViewById(R.id.layout_account_password).setOnClickListener(this);
        // findViewById(R.id.layout_phone_number).setOnClickListener(this);

        // init view
        UserDetailsResponse user = LocalConfigStore.getInstance().getUser();
        tvPhoneNumber.setText(user.getMobile());
    }


    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.layout_phone_number) {
            startActivity(AccountChangeActivity.newInstance(view.getContext(), AccountChangeActivity.MOBILE_NUMBER));

        } else if (view.getId() == R.id.layout_account_password) {
            startActivity(AccountChangeActivity.newInstance(view.getContext(), AccountChangeActivity.PASSWORD));

        } else if (view.getId() == R.id.tv_unregister) {
            // 注销账号
            startActivity(new Intent(this, AccountUnregisterActivity.class));
        }
    }

}
